﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using WinBudget.Properties;

namespace WinBudget
{
    /// <summary>
    /// Interaction logic for Options.xaml
    /// </summary>
    public partial class Options : Window
    {
        public Options()
        {
            InitializeComponent();
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            comboBox3.Text = Settings.Default.NumberAccounts;
            comboBox2.Text = Settings.Default.HeaderType;
            comboBox1.Text = Settings.Default.HomePage;
            
            if (Settings.Default.FileNameTitleBar == true)
            {
                checkBox1.IsChecked = true;
            }
            else
            {
                checkBox1.IsChecked = false;
            }

            if (Settings.Default.ShowClosedAccts == true)
            {
                checkBox2.IsChecked = true;
            }
            else
            {
                checkBox2.IsChecked = false;
            }

            if (Settings.Default.LoadLastFile == true)
            {
                checkBox3.IsChecked = true;
            }
            else
            {
                checkBox3.IsChecked = false;
            }
        }
        
        private void ListBoxItem_Selected_General(object sender, RoutedEventArgs e)
        {
            gridGeneral.Visibility = System.Windows.Visibility.Visible;
            gridHeaders.Visibility = System.Windows.Visibility.Hidden;
            gridAccounts.Visibility = System.Windows.Visibility.Hidden;

        }
        
        private void ListBoxItem_Selected_Headers(object sender, RoutedEventArgs e)
        {
            gridHeaders.Visibility = System.Windows.Visibility.Visible;
            gridGeneral.Visibility = System.Windows.Visibility.Hidden;
            gridAccounts.Visibility = System.Windows.Visibility.Hidden;
                
        }

        private void ListBoxItem_Selected_Accounts(object sender, RoutedEventArgs e)
        {
            gridAccounts.Visibility = System.Windows.Visibility.Visible;
            gridHeaders.Visibility = System.Windows.Visibility.Hidden;
            gridGeneral.Visibility = System.Windows.Visibility.Hidden;
        }

        private void button6_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }

        private void button4_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }

        private void button2_Click(object sender, RoutedEventArgs e)
        {
            Settings.Default.HeaderType = comboBox2.Text;                       
            Settings.Default.Save();
            this.Close();
        }

        private void button3_Click(object sender, RoutedEventArgs e)
        {
            Settings.Default.FileNameTitleBar = checkBox1.IsChecked.Value;
            Settings.Default.ShowClosedAccts = checkBox2.IsChecked.Value;
            Settings.Default.LoadLastFile = checkBox3.IsChecked.Value;
            Settings.Default.HomePage = comboBox1.Text; 
            Settings.Default.Save();
            this.Close();
        }

        private void button5_Click(object sender, RoutedEventArgs e)
        {
            Settings.Default.NumberAccounts = comboBox3.Text;
            Settings.Default.Save();
            this.Close();
        }
        
    }
}
